/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package caro.app.bussiness;

/**
 *
 * @author NQ
 */
public class UserSession {
    public static final int DISABLE=1;
    public static final int ENABLE=-2;
    private int[][] tmpBoard;
    private int[][] board;
    private String myUsername = null;
    private String currentOpponent = null;
    private int currentValue = -1;
    
    public UserSession(String myUsername){
        this.myUsername = myUsername;
        tmpBoard = new int[ClientUtil.ROWS][ClientUtil.COLUMNS];
        board = new int[ClientUtil.ROWS][ClientUtil.COLUMNS];
        currentValue = -1;
        currentOpponent = null;
        reset();
        enableAllTable();
    }
    
    public void reset(){
        for(int i = 0; i < ClientUtil.ROWS ; i++)
            for(int j = 0; j < ClientUtil.COLUMNS ; j++)
                board[i][j] = -2;
    }
    
    public void check(int r, int c, int val){
        if(isCellValidate(r, c))
            board[r][c] = val;
    }
    public void disableAllTable(){
        for(int i = 0; i < ClientUtil.ROWS ; i++)
            for(int j = 0; j < ClientUtil.COLUMNS ; j++)
                tmpBoard[i][j] = 1;
    }
    public void enableAllTable(){
        for(int i = 0; i < ClientUtil.ROWS ; i++)
            for(int j = 0; j < ClientUtil.COLUMNS ; j++)
                tmpBoard[i][j] = -2;
    }
    public void unCheck(int r, int c){
        if(isCellValidate(r, c))
            board[r][c] = -2;
    }
    public int getValueAt(int r, int c){
        if(isCellValidate(r, c))
            return board[r][c];
        return -1;
    }
    private boolean isCellValidate(int r, int c){
        return (r >= 0 && c >= 0 && r < ClientUtil.ROWS && c < ClientUtil.COLUMNS);
    }

    /**
     * @return the myUsername
     */
    public String getMyUsername() {
        return myUsername;
    }

    /**
     * @param myUsername the myUsername to set
     */
    public void setMyUsername(String myUsername) {
        this.myUsername = myUsername;
    }

    /**
     * @return the currentOpponent
     */
    public String getCurrentOpponent() {
        return currentOpponent;
    }

    /**
     * @param currentOpponent the currentOpponent to set
     */
    public void setCurrentOpponent(String currentOpponent) {
        this.currentOpponent = currentOpponent;
    }

    /**
     * @return the currentValue
     */
    public int getCurrentValue() {
        return currentValue;
    }

    /**
     * @param currentValue the currentValue to set
     */
    public void setCurrentValue(int currentValue) {
        this.currentValue = currentValue;
    }

    /**
     * @return the tmpBoard
     */
    public int[][] getTmpBoard() {
        return tmpBoard;
    }

    /**
     * @return the realBoard
     */
    public int[][] getRealBoard() {
        return board;
    }
    
    
}
